<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label><br/>
      <label size="large" label-width="280px">* * * 液化气充装站泄漏爆炸危害模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — — —</label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="260px">
      <el-form-item label="泄漏口面积AH（单位：m^2）" prop="ah" required>
        <el-input-number step="0.0001" v-model="formData.ah" placeholder="请输入泄漏口面积AH（单位：m^2）"  show-word-limit
                  clearable :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="可燃气体混合物喷射直径（单位：m）" prop="d" required>
        <el-input-number step="0.0001"  v-model="formData.d" placeholder="请输入可燃气体混合物喷射直径（单位：m）" show-word-limit
                  clearable :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="密度（单位：kg/m3）" prop="density" required>
        <el-input-number step="0.0001" v-model="formData.density" placeholder="请输入密度（单位：kg/m3）" show-word-limit
                  clearable :style="{width: '80%'}"></el-input-number>
      </el-form-item>
      <el-form-item label="LPG站储槽的放置方向" prop="direction" required>
        <el-select v-model="formData.direction" placeholder="请选择LPG站储槽的放置方向" clearable
                   :style="{width: '80%'}">
          <el-option v-for="(item, index) in directionOptions" :key="index" :label="item.label"
                     :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="泄漏口距离地面高度h（单位：m）" prop="gh" required>
        <el-input-number step="0.01" v-model="formData.gh" placeholder="请输入泄漏口距离地面高度h（单位：m）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="液位高低H（单位：m）" prop="h" required>
        <el-input-number step="0.01" v-model="formData.h" placeholder="请输入液位高低H（单位：m）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="LPG站储槽的长度（单位：m）" prop="l" required>
        <el-input-number step="0.01" v-model="formData.l" placeholder="请输入LPG站储槽的长度（单位：m）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="LPG名称" prop="name">
        <el-input v-model="formData.name" placeholder="请输入LPG名称" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="储槽的存储压力P（单位：Pa）" prop="p" required>
        <el-input-number step="1" v-model="formData.p" placeholder="请输入储槽的存储压力P（单位：Pa,最小：101325）"clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item label="LPG站储槽的位置" prop="position">
        <el-input v-model="formData.position" placeholder="请输入LPG站储槽的位置" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="泄漏时间t（单位：s）" prop="t" required>
        <el-input-number step="1" v-model="formData.t" placeholder="请输入泄漏时间t（单位：s）" clearable :style="{width: '80%'}">
        </el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>储罐内液面积（m2）:{{Ar}};伤害半径（单位：m）:{{x}};泄露量（单位：kg）:{{W0}};爆炸产生的TNT当量:{{WTNT}};</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleYHQ15} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,

        formData: {
          ah: '',
          d: '',
          density: '',
          direction: undefined,
          gh: undefined,
          h: undefined,
          l: undefined,
          name: undefined,
          p: undefined,
          position: undefined,
          t: undefined,
        },
        rules: {
          ah: [],
          d: [],
          density: [],
          direction: [],
          gh: [],
          h: [],
          l: [],
          name: [],
          p: [],
          position: [],
          t: [],
        },
        directionOptions: [{
          "label": "横放",
          "value": 0
        }, {
          "label": "竖放",
          "value": 1
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleYHQ15(this.formData).then(response => {
          console.log(response)
           this.Ar = response.Ar;
          this.x = response.x;
          this.W0 = response.W0;
          this.WTNT = response.WTNT;
            this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
